Remove signs when performing bots.removeUser #31
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
After performing
bots.removeUser(foo), the controllers signed by that bot are left in an invalid state. Attempting to access the controller sign (just access, not even access its properties or modify it) via the game API produces an error:The error is caused by
StructureController.sign.userreferring to a nonexistent user id, breaking the lookup performed by this getter https://github.com/screeps/engine/blob/97c9d12385fed686655c13b09f5f2457dd83a2bf/src/utils.js#L521-L525 attempting to look up this property https://github.com/screeps/engine/blob/97c9d12385fed686655c13b09f5f2457dd83a2bf/src/game/structures.js#L193.This PR adds a step to removeUser that un-signs controllers signed by the user being removed.
Possible alternative solutions:
StructureController.sign.usernameto be undefined if the user whose id is in sign.user doesn't exist.